package day07;

import java.util.Arrays;
import java.util.Scanner;

public class CalTotalAvg {
    public static void main(String[] args) {
        double[] scores=enterData();
       // Arrays.sort(scores);
        double toal=sum(scores);
        System.out.println("总分为"+toal);

        double avg=avg(scores);
        System.out.println("平均分为："+avg);
    }
    //验证码

    // 平均分；
    public  static  double avg(double[] scores){
        double sum=sum(scores);
        double avgg=sum/(scores.length-2);
        return  avgg;
    }
    //计算总分：
    public static double sum(double[] scores){
        double total=0.0;
        double max=scores[0];
        double min=scores[0];
        for(int i=0;i< scores.length;i++){
            if(max<scores[i]){
                max=scores[i];
            }
            if(min>scores[i]){
                min=scores[i];
            }
            total=total+scores[i];
        }
        total=total-max-min;

//
//        Arrays.sort(scores);
//        double []c=new double[4];
//        System.arraycopy(scores,1,c,0,4);
//        for(int i=0;i<c.length;i++){
//        total=total+c[i];
//        }
        return total;
    }
    //录录成绩：
    public static double[] enterData() {
        Scanner scan = new Scanner(System.in);
        double[] arr = new double[6];
        for (int i = 0; i < arr.length; i++) {
            System.out.println("请输入第" + (i + 1) + "个评委的分数：");
            arr[i] = scan.nextDouble();
        }
        return arr;
    }


//        Scanner scan=new Scanner(System.in);
//        double[] scores = new double[6];
//        for (int i = 0; i < enterData().length; i++) {
//            System.out.println("请输入第" + (i + 1) + "个评委的分数");
//            scores[i] = scan.nextDouble();
//        }
//            return scores;
        }


